#ifndef MUSIC_HANLDER_H
#define MUSIC_HANLDER_H

#include <boost/weak_ptr.hpp>

#include "../model/model_class.h"
#include "../model/client.h"

#include "../event_handler.h"
#include "../listener.h"
#include "../notifier.h"
#include "../network.h"
#include "../singletone.h"
#include "../receiver.h"

#include <list>
using namespace std;

namespace handler {
	class music_handler : public network::event_handler, 
			      public network::listener {
	public:
		music_handler(boost::shared_ptr<network::i_socket> s)
		: _sock(s) {}
		virtual ~music_handler() {}

		virtual network::event_type get_type() const
		{
			return network::RECEIVE;
		}
		virtual boost::shared_ptr<const network::i_socket>
			get_socket() const {return _sock;}
		virtual void handle_event(boost::shared_ptr<network::event> n);
		virtual void notify(const network::notifier *n);

		static boost::shared_ptr<handler::music_handler> create(
			boost::shared_ptr<network::i_socket> sock)
		{
			boost::shared_ptr<handler::music_handler> ptr(
				new handler::music_handler(sock));
			ptr->_this = ptr;
			return ptr;
		}
	private:
		boost::shared_ptr<network::i_socket> _sock;
		boost::weak_ptr<handler::music_handler> _this;
	};
}

#endif
